package com.qding.park.common.core.exceptions;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

/**
 * @ClassName BaseException
 * @Description TODO(异常处理基类)
 * @author Administrator
 * @Date 2016年8月28日 下午8:35:31
 * @version 1.0.0
 */
public class BaseException extends RuntimeException {

	private static final Log _log = LogFactory.getLog(BaseException.class);
	/**
	 * @Field @id : TODO(异常编号,唯一标识一个异常)
	 */
	private String id="";

	/**
	 * @Field @ex : TODO(异常体)
	 */
	private Exception ex;

	/**
	 * @Field @exceptionMessage : TODO(异常消息)
	 */
	private ExceptionMessage exceptionMessage;

	public BaseException(ExceptionMessage exceptionMessage, Exception ex) {

		this.exceptionMessage = exceptionMessage;
		this.ex = ex;
	}

	public BaseException(String id,Exception ex, ExceptionMessage exceptionMessage) {
		this.id = id;
		this.exceptionMessage = exceptionMessage;
		this.ex = ex;
	}

	/**
	 * @Description (异常处理)
	 */
	public void handle() {
		
		_log.error("exception id="+this.id);
		if(ex!=null){
			_log.error(ex.getMessage(), ex);
		}
		_log.error("业务根源::", this);
	}

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public Exception getEx() {
		return ex;
	}

	public void setEx(Exception ex) {
		this.ex = ex;
	}

	public ExceptionMessage getExceptionMessage() {
		return exceptionMessage;
	}

	public void setExceptionMessage(ExceptionMessage exceptionMessage) {
		this.exceptionMessage = exceptionMessage;
	}

}
